<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{baseui/head :: head}">
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta name="description" content="牧中智慧畜牧大数据云平台"/>
    <meta name="author" content="牧中(上海)物联网科技有限公司"/>
    <link rel="shortcut icon" href="/webjars/images/favicon.png"/>
    <link rel="stylesheet" href="/webjars/js/layui/css/layui.css" media="all">
    <title>牧中智慧畜牧大数据云平台V1.0</title>


</head>
<style>
    input {

        font-size: 14px;
        color: #0e90d2;

    }

</style>
<body style="background-color:#fff">

<div class="wrapper wrapper-content" style="margin-top: 50px;">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">

                    <div class="row">


                        <div class='row'>
                            <div class='col-sm-6'>
                                <div class='form-group'>
                                    <label class="col-sm-3 control-label text-right">机构名称：</label>
                                    <input class="col-sm-6" id="organization" value="" type="text"/>
                                </div>
                            </div>
                            <input hidden="hidden" id="organizationId" value=""/>
                            <input hidden="hidden" id="organizationType" value=""/>
                            <div class='col-sm-6'>
                                <input id="hidName" value="" hidden="hidden"/>
                                <div class='form-group'>
                                    <label id="lab" class="col-sm-3 control-label text-right">负责人：</label>
                                    <select style="width: 150px; height: 30px;"
                                            id="name">
                                        <option value="0">请选择</option>


                                    </select>

                                </div>
                            </div>

                        </div>


                    </div>


                </div>


            </div>

        </div>
    </div>

</div>
<span id="message" style="margin-left: 300px;color: red;font-size: 18px;"></span>
<script type="text/javascript" src="/webjars/js/jquery.js"></script>
<script type="text/javascript" src="/webjars/js/jquery.gritter/js/jquery.gritter.js"></script>

<script type="text/javascript" src="/webjars/js/jquery.nanoscroller/jquery.nanoscroller.js"></script>
<script type="text/javascript" src="/webjars/js/behaviour/general.js"></script>
<script src="/webjars/js/jquery.ui/jquery-ui.js" type="text/javascript"></script>

<script type="text/javascript" src="/webjars/js/jquery.nestable/jquery.nestable.js"></script>
<script type="text/javascript" src="/webjars/js/bootstrap.switch/bootstrap-switch.min.js"></script>
<script type="text/javascript"
        src="/webjars/js/bootstrap.datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script src="/webjars/js/jquery.select2/select2.min.js" type="text/javascript"></script>
<script src="/webjars/js/skycons/skycons.js" type="text/javascript"></script>
<script src="/webjars/js/bootstrap.slider/js/bootstrap-slider.js" type="text/javascript"></script>
<script type="text/javascript" src="/webjars/js/jquery.niftymodals/js/jquery.modalEffects.js"></script>
<script type="text/javascript" src="/webjars/js/bootstrap.summernote/dist/summernote.min.js"></script>


<script type="text/javascript" src="/webjars/js/jquery.magnific-popup/dist/jquery.magnific-popup.min.js"></script>


<script src="/webjars/js/behaviour/voice-commands.js"></script>
<script src="/webjars/js/bootstrap/dist/js/bootstrap.min.js"></script>

<script type="text/ecmascript" src="/webjars/jqgrid/js/i18n/grid.locale-cn.js"></script>
<script type="text/ecmascript" src="/webjars/jqgrid/js/jquery.jqGrid.min.js"></script>
<script src="/webjars/js/laydate/laydate.js"></script>
<script src="//vuejs.org/js/vue.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
<script src="/webjars/js/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    $(document).ready(function () {
        App.init();

    });
    var int = window.setInterval(showalert, 500);
    function showalert() {
        var organizationId = $("#organizationId").val();
        var organizationType = $("#organizationType").val();
        if (organizationId == null || organizationId == "" || organizationType == null || organizationType == "") {

        } else {
            $.ajax({
                url: '/management/organization/showUpdate',
                dataType: 'json',
                data: {
                    id: organizationId,
                    type: organizationType
                },
                async: false,
                success: function (data) {
                    if(data["type"]==1){
                        var user = "";
                        $.each(data.users, function (index, item) {
                            if (item.userId == data.selectUser) {
                                user += "<option value='" + item.userId + "' selected='selected'>" + item.userName + "</option>";
                            } else {
                                user += "<option value='" + item.userId + "'>" + item.userName + "</option>";
                            }
                        })
                        $("#name").append(user);
                        $("#organization").val(data.name);
                    }else{
                        $("#lab").html("上级组织");
                        var user = "";
                        $.each(data.governments, function (index, item) {
                            if (item.id == data.selectGov) {
                                user += "<option value='" + item.id + "' selected='selected'>" + item.name + "</option>";
                            } else {
                                user += "<option value='" + item.id + "'>" + item.name + "</option>";
                            }
                        })

                        $("#name").append(user);
                        $("#organization").val(data.name);
                    }

                }
            });

            window.clearInterval(int);
        }
    }
</script>


</body>
</html>
